﻿namespace EFS.RC.Wallboard.Common.Config.Sections.Phones
{
	public class Phone
	{
		public Phone(System.Configuration.ConfigurationSectionGroup sectionGroup)
		{
			LoadConfig(sectionGroup);
		}

		#region Properties
		public System.String Uri { get; private set; }

		/// Property Profile: Get, Set
		public EFS.RC.Wallboard.Common.Config.Sections.Phones.Profiles.Profile Profile { get; private set; }
		#endregion

		/// LoadConfig
		private void LoadConfig(System.Configuration.ConfigurationSectionGroup sectionGroup)
		{
			// check
			EFS.Common.Verify.Reference(sectionGroup, "sectionGroup");

			// set
			Uri = GetUriFromSectionName(sectionGroup.Name);
			Profile = new EFS.RC.Wallboard.Common.Config.Sections.Phones.Profiles.Profile(sectionGroup.SectionGroups["Profile"]);
		}

		/// GetUriFromSectionName
		public static System.String GetUriFromSectionName(System.String sectionName)
		{
			// check
			EFS.Common.Verify.String(sectionName, "sectionName");

			// ok
			return
				System.String.Format("{0}{1}",
					EFS.RC.Wallboard.Common.Config.Sections.Phones.Common.UriSectionNumberPrefix,
					EFS.Common.Functions.String.GetTrimmedString(sectionName).Replace("_", ""));
		}
	}

}